package city.spring.modules.medicalstation.medicationRecordDrug.vo;

import city.spring.action.model.AbstractMedicationRecord;
import city.spring.modules.medicalstation.medicationRecordDrug.entity.MedicationRecordDrugExtEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;

/**
 * @author 谢金婷
 * @date 2020/10/26
 * @see MedicationRecordDrugExtEntity
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class MedicationRecordDrugVO extends MedicationRecordDrugExtEntity {
    /**
     * 药品名称
     */
    private String name;

    /**
     * 转换成出库时所需要的对象
     *
     * @return AbstractPlanUser
     */
    public AbstractMedicationRecord<MedicationRecordDrugVO> toMedicationRecord() {
        MedicationRecordDrugVO item = this;
        return new AbstractMedicationRecord<MedicationRecordDrugVO>() {

            @Override
            public Object getKey() {
                return item.getMedicationrecordId();
            }

            @Override
            public String getName() {
                return item.getName();
            }

            @Override
            public BigDecimal getQuantity() {
                return item.getQuantity();
            }

            @Override
            public MedicationRecordDrugVO getObject() {
                return item;
            }
        };
    }

}
